<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use App\Engine\BaseModel;
use Illuminate\Database\Eloquent\Model;
use App\Models\CustomThrough;

/**
 * Class Custom
 *
 * @property int $id
 * @property int $uid
 * @property int $through
 * @property string|null $name
 * @property string|null $label
 * @property float|null $rate
 * @property string|null $phone
 * @property string|null $qrcode
 * @property string|null $content
 * @property string|null $work
 *
 * @package App\Models
 */
class Custom extends BaseModel
{
	protected $table = 'customs';
	public $timestamps = false;

	protected $casts = [
		'uid' => 'int',
		'rate' => 'float'
	];

	public $with=["user"];

	protected $fillable = [
		'uid',
		'name',
		'label',
		'rate',
		'phone',
		'qrcode',
		'content',
        'header',
        'work',
        'mail',
        'wx',
        'address',
        'landline',
        'sign',
        'through'
	];

    public $rule=[
        'uid'=>'required',
        'name'=>'required',
        'phone'=>'required',
        'qrcode'=>'required',
        'content'=>'required',
        'header'=>'required',

    ];
    public $ruleMessage=[
        'name.required'=>"请输入姓名",
        'uid.required'=>"请选择用户",
        'phone.required'=>"号码不能为空",
        'qrcode.required'=>"请上传微信码",
        'content.required'=>"请填写介绍",
        'header.required'=>"请选择头像",
    ];

    public function through()
    {
        return $this->hasMany("App\Models\CustomThrough","aid","id");
    }

    public function star()
    {
        return $this->hasMany("App\Models\CustomStar","aid","id");
    }

}
